package com.ctshk.rpc.certificate.mapper;

import com.ctshk.rpc.certificate.base.CustomBaseMapper;
import com.ctshk.rpc.certificate.dto.CertificateBusinessBookingTimeDetailsDTO;
import com.ctshk.rpc.certificate.entity.CertificateBusinessBookingTime;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

/**
 * <p>
 * 证件业务-预约时段 Mapper 接口
 * </p>
 *
 * @author 谢诗宏
 * @since 2021-03-19
 */
public interface CertificateBusinessBookingTimeMapper extends CustomBaseMapper<CertificateBusinessBookingTime> {

    @Select("SELECT\n" +
            "\tt.start_date,\n" +
            "\tt.end_date,\n" +
            "\td.* \n" +
            "FROM\n" +
            "\t`t_certificate_business_booking_time` t\n" +
            "\tJOIN t_certificate_business_booking_time_details d ON d.time_id = t.id \n" +
            "WHERE\n" +
            "\tt.business_id = #{businessId} \n" +
            "\tAND d.business_hall_id = #{businessHallId} \n" +
            "\tAND t.start_date >= #{beginTime} \n" +
            "\tAND t.end_date <= #{endTime}")
    List<CertificateBusinessBookingTimeDetailsDTO> selectWithDetailsList(@Param("businessId") Long businessId,
                                                                         @Param("beginTime") LocalDate beginTime,
                                                                         @Param("endTime") LocalDate endTime,
                                                                         @Param("businessHallId") Long businessHallId);
}
